package cn.szabadsag.hrm.scheduletask;

import cn.szabadsag.hrm.service.IKillCourseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 发布秒杀课程到缓存的定时任务
 * @author yangcong
 * @date 2022年04月21日 21:03
 * @since
 */
@Component
@Slf4j
public class PublishCourseTask {

    @Autowired
    private IKillCourseService killCourseService;


    /**
     * 发布秒杀课程到Redis
     */
    @Scheduled(cron = "0/5 * * * * ?")
    //@Async//  该方法使用多线程调用
    public void publisCourse2Redis(){
        log.info("发布秒杀课程到Redis，定时任务执行");
        //  发布秒杀课程到Redis
        killCourseService.publisCourse2Redis();

    }
}
